package com.zpark.controller;

import com.zpark.pojo.Person;
import com.zpark.service.IPersonService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @PackageName: com.zpark.controller
 * @ClassName: PersonController
 * @Description:
 * @author: RZS
 * @date: 2024/3/6  9:48
 */
@RestController
@RequestMapping("/p")
public class PersonController {

    // 自动注入业务层对象
    @Autowired
    private IPersonService personService;

    @RequestMapping("/find")
    public Person findByName(String name){
        return personService.findByUsername(name);
    }

    @RequestMapping("/{id}")  // {id}表示采用路径传递参数
    public Person findById(@PathVariable Integer id){
        return personService.findById(id);
    }
}
